﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

/// <summary>
/// Summary description for PropertyData
/// </summary>
public class Property_Data
{
    private SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
	public Property_Data()
	{
   
	}
    public DataSet Search(String pSearch) 
    {
        SqlDataAdapter cmdSearch = new SqlDataAdapter("property_search", conn);
        cmdSearch.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
        cmdSearch.SelectCommand.Parameters.Add("@strSearch", System.Data.SqlDbType.VarChar, 50);
        cmdSearch.SelectCommand.Parameters["@strSearch"].Value = pSearch;

        conn.Open();

        DataSet ds = new DataSet();

        cmdSearch.Fill(ds);
        conn.Close();
        cmdSearch.Dispose();

        return ds;
    }
    public DataSet GetDetails(int pPropertyId)
    {
        SqlDataAdapter cmdSearch = new SqlDataAdapter("property_get_details_by_propertyid", conn);
        cmdSearch.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
        cmdSearch.SelectCommand.Parameters.Add("@Property_Id", System.Data.SqlDbType.Int);
        cmdSearch.SelectCommand.Parameters["@Property_Id"].Value = pPropertyId;

        conn.Open();

        DataSet ds = new DataSet();

        cmdSearch.Fill(ds);
        conn.Close();
        cmdSearch.Dispose();

        return ds;
    }
    public DataSet GetCompTransfers(int pPropertyId, DateTime pBeginDate, DateTime pEndDate, bool pForeclosures)
    {
        SqlDataAdapter cmdSearch = new SqlDataAdapter("property_get_comptransfers", conn);
        cmdSearch.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
        cmdSearch.SelectCommand.Parameters.Add("@Property_Id", System.Data.SqlDbType.Int);
        cmdSearch.SelectCommand.Parameters["@Property_Id"].Value = pPropertyId;
        cmdSearch.SelectCommand.Parameters.Add("@BeginDate", System.Data.SqlDbType.DateTime);
        cmdSearch.SelectCommand.Parameters["@BeginDate"].Value = pBeginDate;
        cmdSearch.SelectCommand.Parameters.Add("@EndDate", System.Data.SqlDbType.DateTime);
        cmdSearch.SelectCommand.Parameters["@EndDate"].Value = pEndDate;
        cmdSearch.SelectCommand.Parameters.Add("@Foreclosures", System.Data.SqlDbType.Bit);
        cmdSearch.SelectCommand.Parameters["@Foreclosures"].Value = pForeclosures;

        conn.Open();

        DataSet ds = new DataSet();

        cmdSearch.Fill(ds);
        conn.Close();
        cmdSearch.Dispose();

        return ds;
    }
}
